package com.xmy.cultivate.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xmy.cultivate.entity.CommonCause;
import com.xmy.cultivate.service.ICommonCauseService;
import com.xmy.cultivate.util.Code;
import com.xmy.cultivate.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 原因表 前端控制器
 * </p>
 *
 * @author hpiggy
 * @since 2025-04-02
 */
@RestController
@RequestMapping("/api/commonCause")
public class CommonCauseController {

    @Autowired
    ICommonCauseService iCommonCauseService;

    @RequestMapping("")
    public Result getCommonCauseList(@RequestParam(value = "type") String type){
        QueryWrapper<CommonCause> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("type",type);
        queryWrapper.eq("deleted",0);
        queryWrapper.eq("status",1);
        List<CommonCause> commonCauseList = iCommonCauseService.list(queryWrapper);

        return new Result(Code.OK,commonCauseList,Code.GET_OK_MSG);
    }

}
